#include<stdio.h>
#include<stdbool.h>

int countValidWords(char *sentence)
{
    int ans = 0;
    char *p = NULL;
    for (p = strtok(sentence, " "); p; p = strtok(NULL, " "))
    {
        int len = strlen(p), i = 0, cnt = 0;
        if (p[0] == '-' || p[len - 1] == '-')
            continue;
        for (; i < len; i++)
        {
            if (isdigit(p[i])) // 排除数字
                break;
            else if (!isalpha(p[i]) && p[i] != '-' && i != len - 1) // 排除不在末尾的标点
                break;
            else if (p[i] == '-' && i > 0 && i < len - 1) // 排除-
            {
                if (cnt == 1 || !isalpha(p[i - 1]) || !isalpha(p[i + 1]))
                    break;
                cnt++;
            }
        }
        if (i == len)
            ans++;
    }
    return ans;
}